home *** CD-ROM | disk | FTP | other *** search
- From: jef@webster.UUCP (Jef Poskanzer)
- Newsgroups: comp.sources.misc
- Subject: v02i082: pbm - Portable Bitmap programs, Part 4/4
- Message-ID: <8803292002.AA24567@webster.sybase.uucp>
- Date: 29 Mar 88 20:02:59 GMT
- Approved: allbery@ncoast.UUCP
-
- comp.sources.misc: Volume 2, Issue 82
- Submitted-By: "Jef Poskanzer" <jef@webster.UUCP>
- Archive-Name: pbm/Part4
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # pbmcrop.c
- # pbmcrop.man
- # pbmtrnspos.c
- # pbmtrnspos.man
- # pbmcut.c
- # pbmcut.man
- # pbmpaste.c
- # pbmpaste.man
- # xxxtopbm.c
- # xxxtopbm.man
- # pbmenlarge.c
- # pbmenlarge.man
- # pbmmake.c
- # pbmmake.man
- # libpbm.c
- # pbm.h
- # pbm.man
- # bmaliases
- # bit_reverse.h
- # This archive created: Mon Mar 28 12:12:11 1988
- # By: Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal)
- export PATH; PATH=/bin:$PATH
- echo shar: extracting "'pbmcrop.c'" '(2955 characters)'
- if test -f 'pbmcrop.c'
- then
- echo shar: will not over-write existing file "'pbmcrop.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmcrop.c'
- X/* pbmcrop.c - crop a portable bitmap
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits, **newbits, background;
- X int argn, backdefault, c;
- X int rows, cols, row, col, newrows, newcols;
- X int top, bottom, left, right;
- X char *usage = "usage: %s [-0] [-1] [pbmfile]\n";
- X
- X argn = 1;
- X backdefault = 1;
- X
- X /* Check for flags. */
- X if ( argc > argn )
- X {
- X if ( argv[argn][0] == '-' )
- X {
- X if ( strcmp( argv[argn], "-0" ) == 0 )
- X {
- X backdefault = 0;
- X background = 0;
- X argn++;
- X }
- X else if ( strcmp( argv[argn], "-1" ) == 0 )
- X {
- X backdefault = 0;
- X background = 1;
- X argn++;
- X }
- X else
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X }
- X }
- X
- X if ( argc > argn + 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X if ( argc == argn + 1 )
- X {
- X ifd = fopen( argv[argn], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[argn] );
- X exit( 1 );
- X }
- X }
- X else
- X ifd = stdin;
- X
- X bits = pbm_readpbm( ifd, &cols, &rows );
- X
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X if ( backdefault )
- X {
- X /* Make a reasonable guess as to what the background is. */
- X c = (int) bits[0][0] + (int) bits[0][cols-1] +
- X (int) bits[rows-1][0] + (int) bits[rows-1][cols-1];
- X background = ( c <= 2 ) ? 0 : 1;
- X }
- X
- X /* Find first non-background line. */
- X for ( top = 0; top < rows; top++ )
- X for ( col = 0; col < cols; col++ )
- X if ( bits[top][col] != background )
- X goto gottop;
- Xgottop:
- X
- X /* Find last non-background line. */
- X for ( bottom = rows-1; bottom >= top; bottom-- )
- X for ( col = 0; col < cols; col++ )
- X if ( bits[bottom][col] != background )
- X goto gotbottom;
- Xgotbottom:
- X
- X /* Find first non-background column. */
- X for ( left = 0; left < cols; left++ )
- X for ( row = top; row < bottom; row++ )
- X if ( bits[row][left] != background )
- X goto gotleft;
- Xgotleft:
- X
- X /* Find last non-background column. */
- X for ( right = cols-1; right > left; right-- )
- X for ( row = top; row <= bottom; row++ )
- X if ( bits[row][right] != background )
- X goto gotright;
- Xgotright:
- X
- X /* Now copy into a new array. */
- X newcols = right - left + 1;
- X newrows = bottom - top + 1;
- X newbits = pbm_allocarray( newcols, newrows );
- X for ( row = top; row <= bottom; row++ )
- X for ( col = left; col <= right; col++ )
- X newbits[row-top][col-left] = bits[row][col];
- X
- X pbm_writepbm( stdout, newbits, newcols, newrows );
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 2955 -ne "`wc -c < 'pbmcrop.c'`"
- then
- echo shar: error transmitting "'pbmcrop.c'" '(should have been 2955 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmcrop.man'" '(1124 characters)'
- if test -f 'pbmcrop.man'
- then
- echo shar: will not over-write existing file "'pbmcrop.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmcrop.man'
- X.TH pbmcrop 1 "13 February 1988"
- X.SH NAME
- Xpbmcrop - crop a portable bitmap
- X.SH SYNOPSIS
- Xpbmcrop [-0] [-1] [pbmfile]
- X.SH DESCRIPTION
- XReads a portable bitmap as input.
- XRemoves edges that are the background color,
- Xand produces a portable bitmap as output.
- XBy default, it makes a guess as to what the background
- Xcolor is.
- XYou can override the default with the -0 and -1 flags.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmtrnspos(1), pbmcut(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1124 -ne "`wc -c < 'pbmcrop.man'`"
- then
- echo shar: error transmitting "'pbmcrop.man'" '(should have been 1124 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmtrnspos.c'" '(1332 characters)'
- if test -f 'pbmtrnspos.c'
- then
- echo shar: will not over-write existing file "'pbmtrnspos.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmtrnspos.c'
- X/* pbmtrnspos.c - read a portable bitmap and transpose it x for y
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits, **newbits;
- X int rows, cols, row, col;
- X
- X if ( argc > 2 )
- X {
- X fprintf( stderr, "usage: %s [pbmfile]\n", argv[0] );
- X exit( 1 );
- X }
- X
- X if ( argc == 2 )
- X {
- X ifd = fopen( argv[1], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[1] );
- X exit( 1 );
- X }
- X }
- X else
- X ifd = stdin;
- X
- X bits = pbm_readpbm( ifd, &cols, &rows );
- X
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X newbits = pbm_allocarray( rows, cols ); /* note parameter reversal */
- X
- X for ( row = 0; row < rows; row++ )
- X for ( col = 0; col < cols; col++ )
- X newbits[col][row] = bits[row][col];
- X
- X pbm_writepbm( stdout, newbits, rows, cols ); /* reversed again */
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 1332 -ne "`wc -c < 'pbmtrnspos.c'`"
- then
- echo shar: error transmitting "'pbmtrnspos.c'" '(should have been 1332 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmtrnspos.man'" '(1318 characters)'
- if test -f 'pbmtrnspos.man'
- then
- echo shar: will not over-write existing file "'pbmtrnspos.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmtrnspos.man'
- X.TH pbmtrnspos 1 "18 February 1988"
- X.SH NAME
- Xpbmtrnspos - transpose a portable bitmap x for y
- X.SH SYNOPSIS
- Xpbmtrnspos [pbmfile]
- X.SH DESCRIPTION
- XReads a portable bitmap as input.
- XTransposes it x for y and produces a portable bitmap as output.
- X.PP
- XNote that transposition is not rotation, but can be used to produce it.
- XFor example, if you wanted a 90 degree clockwise rotation, perhaps for
- Xprinting a landscape bitmap on a laser printer, you could
- Xdo 'pbmtrnspos | pbmfliplr' or 'pbmfliptb | pbmtrnspos'.
- XFor counter-clockwise rotation, you would use the opposite flips.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmcut(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1318 -ne "`wc -c < 'pbmtrnspos.man'`"
- then
- echo shar: error transmitting "'pbmtrnspos.man'" '(should have been 1318 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmcut.c'" '(2606 characters)'
- if test -f 'pbmcut.c'
- then
- echo shar: will not over-write existing file "'pbmcut.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmcut.c'
- X/* pbmcut.c - cut a rectangle out of a portable bitmap
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits, **newbits;
- X int rows, cols, x, y, width, height, row, col;
- X char *usage = "usage: %s x y width height [pbmfile]\n";
- X
- X
- X if ( argc < 5 || argc > 6 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X if ( sscanf( argv[1], "%d", &x ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( argv[2], "%d", &y ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( argv[3], "%d", &width ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( argv[4], "%d", &height ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X if ( x < 0 )
- X {
- X fprintf( stderr, "x is less than 0\n" );
- X exit( 1 );
- X }
- X if ( y < 0 )
- X {
- X fprintf( stderr, "y is less than 0\n" );
- X exit( 1 );
- X }
- X if ( width < 1 )
- X {
- X fprintf( stderr, "width is less than 1\n" );
- X exit( 1 );
- X }
- X if ( height < 1 )
- X {
- X fprintf( stderr, "height is less than 1\n" );
- X exit( 1 );
- X }
- X
- X if ( argc == 6 )
- X {
- X ifd = fopen( argv[5], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[5] );
- X exit( 1 );
- X }
- X }
- X else
- X ifd = stdin;
- X
- X bits = pbm_readpbm( ifd, &cols, &rows );
- X
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X if ( x >= cols )
- X {
- X fprintf(
- X stderr, "x is too large -- the bitmap has only %d cols\n", cols );
- X exit( 1 );
- X }
- X if ( y >= rows )
- X {
- X fprintf(
- X stderr, "y is too large -- the bitmap has only %d rows\n", rows );
- X exit( 1 );
- X }
- X if ( x + width > cols )
- X {
- X fprintf(
- X stderr, "x + width is too large by %d pixels\n", x + width - cols );
- X exit( 1 );
- X }
- X if ( y + height > rows )
- X {
- X fprintf(
- X stderr, "y + height is too large by %d pixels\n",
- X y + height - rows );
- X exit( 1 );
- X }
- X
- X newbits = pbm_allocarray( width, height );
- X for ( row = y; row < y + height; row++ )
- X for ( col = x; col < x + width; col++ )
- X newbits[row-y][col-x] = bits[row][col];
- X
- X pbm_writepbm( stdout, newbits, width, height );
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 2606 -ne "`wc -c < 'pbmcut.c'`"
- then
- echo shar: error transmitting "'pbmcut.c'" '(should have been 2606 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmcut.man'" '(1016 characters)'
- if test -f 'pbmcut.man'
- then
- echo shar: will not over-write existing file "'pbmcut.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmcut.man'
- X.TH pbmcut 1 "19 February 1988"
- X.SH NAME
- Xpbmcut - cut a rectangle out of a portable bitmap
- X.SH SYNOPSIS
- Xpbmcut x y width height [pbmfile]
- X.SH DESCRIPTION
- XReads a portable bitmap as input.
- XExtracts the specified rectangle,
- Xand produces a portable bitmap as output.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1016 -ne "`wc -c < 'pbmcut.man'`"
- then
- echo shar: error transmitting "'pbmcut.man'" '(should have been 1016 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmpaste.c'" '(2402 characters)'
- if test -f 'pbmpaste.c'
- then
- echo shar: will not over-write existing file "'pbmpaste.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmpaste.c'
- X/* pbmpaste.c - paste a rectangle into a portable bitmap
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits1, **bits2;
- X int rows1, cols1, x, y, rows2, cols2, row, col;
- X char *usage = "usage: %s frompbmfile x y [intopbmfile]\n";
- X
- X
- X if ( argc < 4 || argc > 5 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X ifd = fopen( argv[1], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[1] );
- X exit( 1 );
- X }
- X bits1 = pbm_readpbm( ifd, &cols1, &rows1 );
- X fclose( ifd );
- X
- X if ( sscanf( argv[2], "%d", &x ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( argv[3], "%d", &y ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X if ( x < 0 )
- X {
- X fprintf( stderr, "x is less than 0\n" );
- X exit( 1 );
- X }
- X if ( y < 0 )
- X {
- X fprintf( stderr, "y is less than 0\n" );
- X exit( 1 );
- X }
- X
- X if ( argc == 5 )
- X {
- X ifd = fopen( argv[4], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[4] );
- X exit( 1 );
- X }
- X }
- X else
- X ifd = stdin;
- X bits2 = pbm_readpbm( ifd, &cols2, &rows2 );
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X if ( x >= cols2 )
- X {
- X fprintf(
- X stderr, "x is too large -- the second bitmap has only %d cols\n",
- X cols2 );
- X exit( 1 );
- X }
- X if ( y >= rows2 )
- X {
- X fprintf(
- X stderr, "y is too large -- the second bitmap has only %d rows\n",
- X rows2 );
- X exit( 1 );
- X }
- X if ( x + cols1 > cols2 )
- X {
- X fprintf(
- X stderr, "x + width is too large by %d pixels\n",
- X x + cols1 - cols2 );
- X exit( 1 );
- X }
- X if ( y + rows1 > rows2 )
- X {
- X fprintf(
- X stderr, "y + height is too large by %d pixels\n",
- X y + rows1 - rows2 );
- X exit( 1 );
- X }
- X
- X for ( row = 0; row < rows1; row++ )
- X for ( col = 0; col < cols1; col++ )
- X bits2[row+y][col+x] = bits1[row][col];
- X
- X pbm_writepbm( stdout, bits2, cols2, rows2 );
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 2402 -ne "`wc -c < 'pbmpaste.c'`"
- then
- echo shar: error transmitting "'pbmpaste.c'" '(should have been 2402 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmpaste.man'" '(1334 characters)'
- if test -f 'pbmpaste.man'
- then
- echo shar: will not over-write existing file "'pbmpaste.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmpaste.man'
- X.TH pbmpaste 1 "19 February 1988"
- X.SH NAME
- Xpbmpaste - paste a rectangle into a portable bitmap
- X.SH SYNOPSIS
- Xpbmpaste frompbmfile x y [intopbmfile]
- X.SH DESCRIPTION
- XReads two portable bitmaps as input.
- XInserts the first bitmap into the second at the specified location,
- Xand produces a portable bitmap as output.
- X.PP
- XThis is most useful in combination with pbmcut(1).
- XFor instance, if you want to edit a small segment of a large
- Xbitmap, and your bitmap editor is TOO STUPID to edit the
- Xlarge bitmap, you can cut out the segment you are interested in,
- Xedit it, and then paste it back in.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1), pbmcut(1),
- Xpbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1334 -ne "`wc -c < 'pbmpaste.man'`"
- then
- echo shar: error transmitting "'pbmpaste.man'" '(should have been 1334 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'xxxtopbm.c'" '(2171 characters)'
- if test -f 'xxxtopbm.c'
- then
- echo shar: will not over-write existing file "'xxxtopbm.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'xxxtopbm.c'
- X/* xxxtopbm.c - read an xxx bitmap and write a portable bitmap
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits, getbit();
- X int rows, cols, row, col, subcol;
- X
- X if ( argc > 2 )
- X {
- X fprintf( stderr, "usage: %s [xxxfile]\n", argv[0] );
- X exit( 1 );
- X }
- X
- X if ( argc == 2 )
- X {
- X ifd = fopen( argv[1], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[1] );
- X exit( 1 );
- X }
- X }
- X else
- X ifd = stdin;
- X
- X getinit( ifd, &cols, &rows );
- X
- X bits = pbm_allocarray( cols, rows );
- X
- X for ( row = 0; row < rows; row++ )
- X for ( col = 0; col < cols; col += 8 )
- X for ( subcol = col + 7; subcol >= col; subcol-- )
- X bits[row][subcol] = getbit( ifd );
- X
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X pbm_writepbm( stdout, bits, cols, rows );
- X
- X exit( 0 );
- X }
- X
- X
- Xint item, bitsperitem, bitshift;
- X
- Xgetinit( file, colp, rowp )
- XFILE *file;
- Xint *colp, *rowp;
- X {
- X if ( getc( file ) != 109 )
- X {
- X fprintf( stderr, "Bad magic number 1.\n" );
- X exit( 1 );
- X }
- X if ( getc( file ) != 1 )
- X {
- X fprintf( stderr, "Bad magic number 2.\n" );
- X exit( 1 );
- X }
- X *colp = getc( file );
- X *colp += getc( file ) << 8;
- X *rowp = getc( file );
- X *rowp += getc( file ) << 8;
- X bitsperitem = 8;
- X if ( getc( file ) != 0 )
- X {
- X fprintf( stderr, "Bad magic number 3.\n" );
- X exit( 1 );
- X }
- X if ( getc( file ) != 46 )
- X {
- X fprintf( stderr, "Bad magic number 4.\n" );
- X exit( 1 );
- X }
- X }
- X
- Xbit
- Xgetbit( file )
- XFILE *file;
- X {
- X bit b;
- X
- X if ( bitsperitem == 8 )
- X {
- X item = getc( file );
- X bitsperitem = 0;
- X bitshift = 7;
- X }
- X bitsperitem++;
- X b = ( item >> bitshift) & 1;
- X bitshift--;
- X return ( b );
- X }
- SHAR_EOF
- if test 2171 -ne "`wc -c < 'xxxtopbm.c'`"
- then
- echo shar: error transmitting "'xxxtopbm.c'" '(should have been 2171 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'xxxtopbm.man'" '(1194 characters)'
- if test -f 'xxxtopbm.man'
- then
- echo shar: will not over-write existing file "'xxxtopbm.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'xxxtopbm.man'
- X.TH xxxtopbm 1 "21 February 1988"
- X.SH NAME
- Xxxxtopbm - convert "xxx" bitmaps into portable bitmaps
- X.SH SYNOPSIS
- Xxxxtopbm [xxxfile]
- X.SH DESCRIPTION
- XReads an "xxx" bitmap as input.
- XProduces a portable bitmap as output.
- X.LP
- X"xxx" bitmaps are the unknown and undocumented format found on
- Xucbvax.Berkeley.Edu in the directory pub/xbackgrounds.
- XThe arrangement of the bits is the same as for Sun rasterfiles, but
- Xthe headers are completely different.
- X.SH "SEE ALSO"
- Xpbm(5), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1), pbmcut(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1194 -ne "`wc -c < 'xxxtopbm.man'`"
- then
- echo shar: error transmitting "'xxxtopbm.man'" '(should have been 1194 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmenlarge.c'" '(1950 characters)'
- if test -f 'pbmenlarge.c'
- then
- echo shar: will not over-write existing file "'pbmenlarge.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmenlarge.c'
- X/* pbmenlarge.c - read a portable bitmap and enlarge it N times
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X FILE *ifd;
- X bit **bits, **newbits;
- X int argn, n, rows, cols, row, col, subrow, subcol;
- X char *usage = "usage: %s [-N] [pbmfile]\n";
- X
- X if ( argc > 3 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X n = 0;
- X ifd = stdin;
- X
- X for ( argn = 1; argn < argc; argn++ )
- X {
- X if ( argv[argn][0] == '-' )
- X {
- X if ( n != 0 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( &(argv[argn][1]), "%d", &n ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( n < 2 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X }
- X else
- X {
- X if ( ifd != stdin )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X ifd = fopen( argv[argn], "r" );
- X if ( ifd == NULL )
- X {
- X fprintf( stderr, "%s: can't open.\n", argv[argn] );
- X exit( 1 );
- X }
- X }
- X }
- X
- X if ( n == 0 )
- X n = 2; /* default to double */
- X
- X bits = pbm_readpbm( ifd, &cols, &rows );
- X
- X if ( ifd != stdin )
- X fclose( ifd );
- X
- X newbits = pbm_allocarray( cols * n, rows * n );
- X
- X for ( row = 0; row < rows; row++ )
- X for ( col = 0; col < cols; col++ )
- X for ( subrow = 0; subrow < n; subrow++ )
- X for ( subcol = 0; subcol < n; subcol++ )
- X newbits[row * n + subrow][col * n + subcol] =
- X bits[row][col];
- X
- X pbm_writepbm( stdout, newbits, cols * n, rows * n );
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 1950 -ne "`wc -c < 'pbmenlarge.c'`"
- then
- echo shar: error transmitting "'pbmenlarge.c'" '(should have been 1950 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmenlarge.man'" '(1044 characters)'
- if test -f 'pbmenlarge.man'
- then
- echo shar: will not over-write existing file "'pbmenlarge.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmenlarge.man'
- X.TH pbmenlarge 1 "29 February 1988"
- X.SH NAME
- Xpbmenlarge - read a portable bitmap and enlarge it N times
- X.SH SYNOPSIS
- Xpbmenlarge [-N] [pbmfile]
- X.SH DESCRIPTION
- XReads a portable bitmap as input.
- XReplicates its bits N times, and produces a portable bitmap as output.
- XThe default enlargement is two.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1), pbmcut(1),
- Xpbmpaste(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 1044 -ne "`wc -c < 'pbmenlarge.man'`"
- then
- echo shar: error transmitting "'pbmenlarge.man'" '(should have been 1044 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmmake.c'" '(1174 characters)'
- if test -f 'pbmmake.c'
- then
- echo shar: will not over-write existing file "'pbmmake.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmmake.c'
- X/* pbmmake.c - create a blank bitmap of a specified size
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xmain( argc, argv )
- Xint argc;
- Xchar *argv[];
- X {
- X bit **bits;
- X int rows, cols, row, col;
- X char *usage = "usage: %s <width> <height>\n";
- X
- X if ( argc != 3 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X if ( sscanf( argv[1], "%d", &cols ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X if ( sscanf( argv[2], "%d", &rows ) != 1 )
- X {
- X fprintf( stderr, usage, argv[0] );
- X exit( 1 );
- X }
- X
- X bits = pbm_allocarray( cols, rows );
- X
- X for ( row = 0; row < rows; row++ )
- X for ( col = 0; col < cols; col++ )
- X bits[row][col] = 0;
- X
- X pbm_writepbm( stdout, bits, cols, rows );
- X
- X exit( 0 );
- X }
- SHAR_EOF
- if test 1174 -ne "`wc -c < 'pbmmake.c'`"
- then
- echo shar: error transmitting "'pbmmake.c'" '(should have been 1174 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbmmake.man'" '(981 characters)'
- if test -f 'pbmmake.man'
- then
- echo shar: will not over-write existing file "'pbmmake.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbmmake.man'
- X.TH pbmmake 1 "24 March 1988"
- X.SH NAME
- Xpbmmake - create a blank bitmap of a specified size
- X.SH SYNOPSIS
- Xpbmmake <width> <height>
- X.SH DESCRIPTION
- XProduces an all-white portable bitmap of the specified width and height.
- X.SH "SEE ALSO"
- Xpbm(5), cbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1), pbmcut(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 981 -ne "`wc -c < 'pbmmake.man'`"
- then
- echo shar: error transmitting "'pbmmake.man'" '(should have been 981 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'libpbm.c'" '(2749 characters)'
- if test -f 'libpbm.c'
- then
- echo shar: will not over-write existing file "'libpbm.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'libpbm.c'
- X/* libpbm.c - pbm utility library
- X**
- X** Copyright (C) 1988 by Jef Poskanzer.
- X**
- X** Permission to use, copy, modify, and distribute this software and its
- X** documentation for any purpose and without fee is hereby granted, provided
- X** that the above copyright notice appear in all copies and that both that
- X** copyright notice and this permission notice appear in supporting
- X** documentation. This software is provided "as is" without express or
- X** implied warranty.
- X*/
- X
- X#include <stdio.h>
- X#include "pbm.h"
- X
- Xint
- Xpbm_getint( file )
- XFILE *file;
- X {
- X char ch;
- X int i;
- X
- X do
- X {
- X ch = pbm_getc( file );
- X }
- X while ( ch == ' ' || ch == '\t' || ch == '\n' );
- X
- X if ( ch < '0' || ch > '9' )
- X {
- X fprintf( stderr, "Junk in file where an integer should be!\n" );
- X exit( 1 );
- X }
- X
- X i = 0;
- X do
- X {
- X i = i * 10 + ch - '0';
- X ch = pbm_getc( file );
- X }
- X while ( ch >= '0' && ch <= '9' );
- X
- X return ( i );
- X }
- X
- X
- Xbit
- Xpbm_getbit( file )
- XFILE *file;
- X {
- X char ch;
- X
- X do
- X {
- X ch = pbm_getc( file );
- X }
- X while ( ch == ' ' || ch == '\t' || ch == '\n' );
- X
- X if ( ch != '0' && ch != '1' )
- X {
- X fprintf( stderr, "Junk in file where bits should be!\n" );
- X exit( 1 );
- X }
- X
- X return ( ( ch == '1' ) ? 1 : 0 );
- X }
- X
- Xchar
- Xpbm_getc( file )
- XFILE *file;
- X {
- X int ich;
- X char ch;
- X
- X ich = getc( file );
- X if ( ich == NULL )
- X {
- X fprintf( stderr, "Premature EOF.\n" );
- X exit( 1 );
- X }
- X ch = (char) ich;
- X
- X if ( ch == '#' )
- X {
- X do
- X {
- X ich = getc( file );
- X if ( ich == NULL )
- X {
- X fprintf( stderr, "Premature EOF.\n" );
- X exit( 1 );
- X }
- X ch = (char) ich;
- X }
- X while ( ch != '\n' );
- X }
- X
- X return ( ch );
- X }
- X
- Xbit **
- Xpbm_allocarray( cols, rows )
- Xint cols, rows;
- X {
- X bit **bits;
- X int i;
- X
- X bits = (bit **) malloc( rows * sizeof( bit *) );
- X for ( i = 0; i < rows; i++ )
- X {
- X bits[i] = (bit *) malloc( cols * sizeof( bit ) );
- X }
- X
- X return ( bits );
- X }
- X
- X
- Xbit **pbm_readpbm( file, colsP, rowsP )
- XFILE *file;
- Xint *colsP, *rowsP;
- X {
- X bit **bits;
- X int row, col;
- X
- X *colsP = pbm_getint( file );
- X *rowsP = pbm_getint( file );
- X
- X bits = pbm_allocarray( *colsP, *rowsP );
- X
- X for ( row = 0; row < *rowsP; row++ )
- X for ( col = 0; col < *colsP; col++ )
- X bits[row][col] = pbm_getbit( file );
- X
- X return ( bits );
- X }
- X
- Xpbm_writepbm( file, bits, cols, rows )
- XFILE *file;
- Xbit **bits;
- Xint cols, rows;
- X {
- X int row, col, linecount;
- X
- X fprintf( file, "%d %d\n", cols, rows );
- X
- X for ( row = 0; row < rows; row++ )
- X {
- X linecount = 0;
- X for ( col = 0; col < cols; col++ )
- X {
- X if ( linecount >= 70 )
- X {
- X putc( '\n', file );
- X linecount = 0;
- X }
- X putc( bits[row][col] ? '1' : '0', file );
- X linecount++;
- X }
- X putc( '\n', file );
- X }
- X }
- SHAR_EOF
- if test 2749 -ne "`wc -c < 'libpbm.c'`"
- then
- echo shar: error transmitting "'libpbm.c'" '(should have been 2749 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbm.h'" '(490 characters)'
- if test -f 'pbm.h'
- then
- echo shar: will not over-write existing file "'pbm.h'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbm.h'
- X/* pbm.h - header file for libpbm portable bitmap library
- X*/
- X
- Xtypedef unsigned char bit;
- X
- X/* Declarations of routines. */
- X
- Xint pbm_getint( );
- X /* i = pbm_getint( file ); */
- Xbit pbm_getbit( );
- X /* b = pbm_getbit( file ); */
- Xchar pbm_getc( );
- X /* c = pbm_getc( file ); */
- Xbit **pbm_allocarray( );
- X /* bits = pbm_allocarray( cols, rows ); bits[row][col]; */
- Xbit **pbm_readpbm( );
- X /* bits = pbm_readpbm( file, &cols, &rows ); */
- Xpbm_writepbm( );
- X /* pbm_writepbm( file, bits, cols, rows ); */
- SHAR_EOF
- if test 490 -ne "`wc -c < 'pbm.h'`"
- then
- echo shar: error transmitting "'pbm.h'" '(should have been 490 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'pbm.man'" '(2415 characters)'
- if test -f 'pbm.man'
- then
- echo shar: will not over-write existing file "'pbm.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'pbm.man'
- X.TH pbm 5 "18 February 1988"
- X.SH NAME
- Xpbm - portable bitmap file format
- X.SH DESCRIPTION
- XThe portable bitmap format is a lowest common denominator.
- XIt was originally designed to make it reasonable to mail bitmaps
- Xbetween different types of machines using the typical stupid network
- Xmailers we have today.
- XNow it serves as the common language of a large family of bitmap
- Xconversion filters.
- XThe definition is as follows:
- X.IP - 2
- XA width, formatted as ASCII characters in decimal.
- X.IP - 2
- XWhitespace (blanks, TABs, CRs, LFs).
- X.IP - 2
- XA height, again in ASCII decimal.
- X.IP - 2
- XWhitespace.
- X.IP - 2
- XWidth * height bits, each either '1' or '0', starting at the top-left
- Xcorner of the bitmap, proceding in normal English reading order.
- X.IP - 2
- XThe character '1' means black, '0' means white.
- X.IP - 2
- XWhitespace in the bits section is ignored.
- X.IP - 2
- XCharacters from a "#" to the next end-of-line are ignored (comments).
- X.IP - 2
- XNo line may be longer than 70 characters.
- X.PP
- XHere is an example of a small bitmap in this format:
- X.PP
- X.nf
- X# feep.pbm
- X24 7
- X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- X0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
- X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
- X0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
- X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
- X0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
- X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- X.fi
- X.PP
- XPrograms that read this format should be as lenient as possible,
- Xaccepting anything that looks remotely like a bitmap.
- XFor instance, the above example does not actually conform to the
- Xstandard, since it has whitespace before the width; neverthless,
- Xit should be accepted.
- X.SH "SEE ALSO"
- Xcbmtopbm(1), icontopbm(1), macptopbm(1), rasttopbm(1), xbmtopbm(1), xwdtopbm(1),
- Xpbmtoicon(1), pbmtocbm(1), pbmtops(1), pbmtoptx(1), pbmtorast(1),
- Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
- Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmtrnspos(1), pbmcut(1),
- Xpbmpaste(1), pbmenlarge(1)
- X.SH AUTHOR
- XCopyright (C) 1988 by Jef Poskanzer.
- X
- XPermission to use, copy, modify, and distribute this software and its
- Xdocumentation for any purpose and without fee is hereby granted, provided
- Xthat the above copyright notice appear in all copies and that both that
- Xcopyright notice and this permission notice appear in supporting
- Xdocumentation. This software is provided "as is" without express or
- Ximplied warranty.
- SHAR_EOF
- if test 2415 -ne "`wc -c < 'pbm.man'`"
- then
- echo shar: error transmitting "'pbm.man'" '(should have been 2415 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'bmaliases'" '(445 characters)'
- if test -f 'bmaliases'
- then
- echo shar: will not over-write existing file "'bmaliases'"
- else
- sed 's/^X//' << \SHAR_EOF > 'bmaliases'
- X# This script must be sourced - it will not work if you run it in a sub-shell.
- X
- Xset _bmtypes="ascii cbm icon macp ps ptx rast xbm x10bm xwd xxx"
- X
- Xforeach i ( $_bmtypes )
- X if ( $i != ascii && $i != ps && $i != ptx && $i != x10bm ) then
- X foreach j ( $_bmtypes )
- X if ( $j != macp && $j != xwd && $j != xxx ) then
- X if ( $i != $j ) then
- X alias ${i}to${j} "( ${i}topbm | pbmto${j} )"
- X endif
- X endif
- X end
- X endif
- Xend
- X
- Xunset _bmtypes
- SHAR_EOF
- if test 445 -ne "`wc -c < 'bmaliases'`"
- then
- echo shar: error transmitting "'bmaliases'" '(should have been 445 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'bit_reverse.h'" '(1994 characters)'
- if test -f 'bit_reverse.h'
- then
- echo shar: will not over-write existing file "'bit_reverse.h'"
- else
- sed 's/^X//' << \SHAR_EOF > 'bit_reverse.h'
- X/*
- X** bit_reverse.h
- X**
- X** This particular array seems to be useful in a lot of bitmap
- X** conversion programs. It's not used in pbm because bits are
- X** stored one per byte, for easier manipulation. But if you wanted
- X** to write, for example, a program to directly convert Sun raster
- X** format into X bitmaps, you could use this.
- X*/
- X
- Xunsigned char bit_reverse[256] = {
- X 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0,
- X 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- X 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4,
- X 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- X 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc,
- X 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- X 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca,
- X 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- X 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6,
- X 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- X 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1,
- X 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- X 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9,
- X 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- X 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd,
- X 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- X 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3,
- X 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- X 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7,
- X 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- X 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf,
- X 0x3f, 0xbf, 0x7f, 0xff};
- SHAR_EOF
- if test 1994 -ne "`wc -c < 'bit_reverse.h'`"
- then
- echo shar: error transmitting "'bit_reverse.h'" '(should have been 1994 characters)'
- fi
- fi # end of overwriting check
- # End of shell archive
- exit 0
-